package com.eamois.dao.manual.impl;

import java.sql.SQLException;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.eamois.dao.impl.BaseDaoImpl;
import com.eamois.dao.manual.CatalogStyleFieldDao;
import com.eamois.domain.manual.CatalogStyle;
import com.eamois.domain.manual.CatalogStyleField;

public class CatalogStyleFieldDaoImpl extends BaseDaoImpl<CatalogStyleField> implements CatalogStyleFieldDao{

	@SuppressWarnings("unchecked")
	public Collection<CatalogStyleField> findCatalogStyleField(
			final CatalogStyle catalogStyle) {
		// TODO Auto-generated method stub
		return (Collection<CatalogStyleField>) this.getHibernateTemplate().execute(new HibernateCallback() {

			@Override
			public Object doInHibernate(Session arg0)
					throws HibernateException, SQLException {
				// TODO Auto-generated method stub
				Criteria criteria = arg0.createCriteria(CatalogStyleField.class);
				criteria.add(Restrictions.eq("catalogStyle", catalogStyle));
				return criteria.list();
			}
			
		});
	}

}
